using MoonFramework.View;
using UnityEngine;

namespace MoonFramework.FSM
{
    public abstract class AttackState : BaseState
    {
        public override void Enter()
        {
            AnimancerManager.Instance.Play(_actor?.viewController._AttackAnimation, _actor?.viewController.AnimancerComponent);
            
            _actor?.viewController.AddAnimationEvent(nameof(StartHit), StartHit);
            _actor?.viewController.AddAnimationEvent(nameof(StopHit), StartHit);
            _actor?.viewController.AddAnimationEvent(nameof(AttackOver), AttackOver);
        }

        /// <summary>
        /// 武器的伤害检测 
        /// </summary>
        protected abstract void CheckHitOnTriggerStay(Collider other, object[] args);

        protected abstract void StartHit();
        
        //让武器停止伤害计算
        protected abstract void StopHit();

        //攻击结束
        protected abstract void AttackOver();
        
        public override void Exit()
        {
            _actor.viewController.RemoveAnimationEvent(nameof(StartHit), StartHit);
            _actor.viewController.RemoveAnimationEvent(nameof(StopHit), StartHit);
            _actor.viewController.RemoveAnimationEvent(nameof(AttackOver), AttackOver);
        }
    }
}